package com.efounder.frame.manager;

/**
 * Created by yqs on 2017/2/3.
 */

import android.content.Context;

import com.efounder.constant.EnvironmentVariable;
import com.efounder.http.EFHttpRequest;


/**
 * 通过http请求Json数据
 */
public class AppAccountRequestHttpDataUtil {


    /**
     * 修改密码
     * @param context
     * @param publicId
     * */
    public static void publicUpgradeByRestFul( Context context,
                                      String publicId,
                                      final PublicUpgradeByRestFulCallBack publicUpgradeByRestFulCallBack) {

        EFHttpRequest httpRequest = new EFHttpRequest(context);
        String baseUrl = EnvironmentVariable.getProperty("RestfulInterface","");
        if(baseUrl.equals("")){
            publicUpgradeByRestFulCallBack.upgradeResponse(3,"请设置RestFul地址");
            return;
        }
        String url =baseUrl
                + "/publicUpgrade?" + "publicId=" + publicId + "&deviceType=android";


        httpRequest.setHttpRequestListener(new EFHttpRequest.HttpRequestListener() {

            @Override
            public void onRequestSuccess(int requestCode, String response) {
                publicUpgradeByRestFulCallBack.upgradeResponse(0,response);

            }

            @Override
            public void onRequestFail(int requestCode, String message) {
                publicUpgradeByRestFulCallBack.upgradeResponse(2,"网络连接失败");

            }
        });
        httpRequest.httpGet(url);
    }
    /**
     * 注册回调
     */
    public interface PublicUpgradeByRestFulCallBack {

        public void upgradeResponse(int responsenum, String response);

    }
}